package com.tang.lottery;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.listener.PageReadListener;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author tmh
 * @date 2024/3/22 21:22
 * @description
 */
@RestController
public class ExcelDemo {

    @GetMapping("/import")
    public void testImport(@RequestBody MultipartFile file) throws Exception {
        EasyExcel.read(file.getInputStream(), Student.class, new PageReadListener<Student>(
                dataList->{
                    for (Student student : dataList) {
                        System.out.println(student.getName());
                        System.out.println(student);
                    }
                }
        )).sheet().doRead();
    }


}
